﻿using System;
using System.Windows.Forms;

namespace mfe_proj.Forms
{
    public partial class RawHtmlForm : Form
    {
        public delegate void RawHtmlFormEventHandler(object sender, RawHtmlEventArgs e);
        public event RawHtmlFormEventHandler ApplyOkClicked;

        public RawHtmlForm()
        {
            InitializeComponent();
        }

        public string Html
        {
            get
            {
                return txtHtml.Text;
            }
            set
            {
                txtHtml.Text = value;
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            OnApplyOkClicked();
            Close();
        }

        void OnApplyOkClicked()
        {
            if (ApplyOkClicked != null)
                ApplyOkClicked(this, new RawHtmlEventArgs(txtHtml.Text));
        }

        public class RawHtmlEventArgs : EventArgs
        {
            public string NewHtml;
            public RawHtmlEventArgs(string _newhtml)
            {
                NewHtml = _newhtml;
            }
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            OnApplyOkClicked();
        }
    }
}
